package com.todo.client.gui.dialog.action;

import java.util.Date;

import com.extjs.gxt.ui.client.data.BeanModel;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.form.TextArea;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.todo.client.gui.dialog.AbstractDialog;

public class ActionDialog extends AbstractDialog{
	
	private TextField<String> name;
	private ComboBox<BeanModel> type;
	private TextField<Date> entryTime;
	private TextField<Date> expirationTime;
	private TextArea description;
	private Button personal;
	

	public ActionDialog(String title) {
		super();
		getDialog(title);
		
        name = getTextField(MESSAGES.name());
        //type = getTypeComboBox(MESSAGES.type(),MESSAGES.emptyText());
        entryTime = getDateTextField(MESSAGES.entryTime());
        expirationTime = getDateTextField(MESSAGES.expirationTime());
        description = getTextArea(MESSAGES.description());
        
        add(name);
        //add(type);
        add(entryTime);
        add(expirationTime);
        add(description);
        
	}
	
	@Override
	protected void createButtons() {
		super.createButtons();
		personal = getButton(MESSAGES.ok());
		Button cancel = getButton(MESSAGES.cancel());
		cancel.addSelectionListener(new SelectionListener<ButtonEvent>() {
			
			@Override
			public void componentSelected(ButtonEvent ce) {
				ActionDialog.this.hide();
				
			}
		});
		
		addButton(personal);
		addButton(cancel);
	}



	private ComboBox<BeanModel> getTypeComboBox(String value, String emptyText){
		ComboBox<BeanModel> field = new ComboBox<BeanModel>();
		field.setFieldLabel(value);
		field.setEmptyText(emptyText);
		return field;
	}
	
	private TextField<Date> getDateTextField(String value){
		TextField<Date> field = new TextField<Date>();
		field.setFieldLabel(value);
		return field;
	}
	
	private TextArea getTextArea(String value){
		TextArea field = new TextArea();
		field.setFieldLabel(value);
		return field;
	}

	@Override
	protected void validate() {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected boolean hasValue() {
		// TODO Auto-generated method stub
		return false;
	}

	public void setPersonal(Button personal) {
		this.personal = personal;
	}

	public Button getPersonal() {
		return personal;
	}

}
